<!-- 张成玉的注册页面 -->
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String msg = "";
	//取共享数据时，一定和放置数据时名字要一致
	msg = (String) request.getAttribute("errormsg");//取数据的时候一定要加上强制类型转换
	if (msg == null) {
		msg = "";
	}
	String msg2 = "";
	msg2 = (String) request.getAttribute("errormsg2");//取数据的时候一定要加上强制类型转换
	if (msg2 == null) {
		msg2 = "";
	}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>12306购票系统</title>
<link href="css/css.css" rel="stylesheet" type="text/css">

<link rel="stylesheet" type="text/css" href="js/tool/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="js/tool/easyui/themes/icon.css">

<script type="text/javascript" src="js/tool/jquery/jquery-3.2.1.min.map"></script>
<script type="text/javascript" src="js/tool/jquery/jquery-3.2.1.min.js"></script>

<!--张成玉- page controller -->
<script type="text/javascript">
	function UserRegistration() {
//		window.navigate("UserRegistration.html");
		window.location.href="UserRegistration.html";
	}
	function UserLogin() {
		window.navigate("Admin/Index.jsp");
	}
	function reloadAuthCode() {
		var auth = document.getElementById('authCode');
		auth.src = '${pageContext.request.contextPath}/auth?dd=' + new Date();

	}
	// ajax提交表单
	$(function(){
		$.ajaxSetup({
	        async: false  /* 张成玉-同步请求 */
	    });
	});
	/* ajax与el表达式 */
	function runsubmit(){		
		$.post('LoginServlet', $("#loginForm").serialize(), function(data) {/* 张成玉-ajax方法获取后台response.getWriter().write()返回的值 */
			var str = new RegExp('success');   /* RegExp:正则表达式regular expression的缩写，显示构造函数 */
			if(!str.test(data)){    /* test()测试String中是否有匹配的字符串是true，否false		 */
				alert(data);
			}else{
				
			}
		});
	}
</script>
<!-- 张成玉jstl标签库表达式 -->
<c:if test="${register=='success' }">
	<script type="text/javascript">
		window.onload=function(){
			alert("注册成功！请登录");
		}
	</script>	
</c:if>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
   <!--  张成玉的登录大表单 -->
	<form id="loginForm" name="form1" method="post" action="">
		<table width="933" border="0" align="center" cellpadding="0"
			cellspacing="0" style="margin:120px;">
			<tr>
				<td height="412" valign="top" background="images/bg_img1.jpg"><table
						height="300" border="0" cellspacing="0">
						<tr>
							<td width="538">&nbsp;</td>
							<td height="130" colspan="6">&nbsp;</td>
						</tr>
						<tr>
							<td rowspan="9">&nbsp;</td>
							<td width="98" height="20" align="right"><img
								src="images/text_yh.gif" width="60" height="18">
							</td>
							<td width="16">&nbsp;</td>
							<td width="136"><input id="username" name="username"
								value="${cookie.loginName.value }" type="text" id="username"
								size="18" /><font color="red"><%=msg%>
							</td>
							<td width="55">&nbsp;</td>
							<td width="44">&nbsp;</td>
							<td width="32">&nbsp;</td>
						</tr>
						<tr>
							<td height="20" align="right">&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
						</tr>
						<tr>
							<td height="20" align="right"><img
								src="images/text_password.gif" width="60" height="18">
							</td>
							<td>&nbsp;</td>
							<td><input id="pwd" name="password" type="password" id="password"
								size="18" />
							</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
						</tr>
						<tr>
							<td height="20" align="right">&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
						</tr>
						<tr>
							<td height="20" align="right"><img src="images/text_yzm.gif"
								width="60" height="18">
							</td>
							<td>&nbsp;</td>
							<td><input name="code" type="text" id="code" size="18" /></br>
							<font color="red"><%=msg2%>
							</td>
							<td><span class="text_cray1"><img id="authCode"
									src="${pageContext.request.contextPath}/auth" alt=""
									height="20" />
							</span>
							</td>
							<td><img src="images/text_sx.gif" onclick="reloadAuthCode()"
								width="32" height="18">
							</td>
							<td align="left">&nbsp;</td>
						</tr>
						<tr>
							<td height="20">&nbsp;</td>
							<td>&nbsp;</td>
							<td colspan="2">&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
						</tr>
						<tr>
							<td height="20">&nbsp;</td>
							<td>&nbsp;</td>
							<td colspan="2"><table width="200" border="0"
									cellspacing="0">
									<tr>
										<td width="78"><button onclick="runsubmit()" class="butlogin"></button>
										</td>
										<td>&nbsp;</td>
										<td width="78">
										<!-- <a class="butzc" href="UserRegistration.html">注册</a> -->
										<input type="button" class="butzc"
											onClick="UserRegistration()" />
										</td>
									</tr>
								</table>
							</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
						</tr>
						<tr>
							<td height="20">&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
							<td>&nbsp;</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</form>
</body>
</html>
